#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> 
#include <wait.h>
#include <pthread.h>
#include <semaphore.h>

sem_t Semaphore;

void *Put_Exosite(void *data)
{
	while(1){
		printf("_");fflush(stdout);
		sem_post(&Semaphore);
		sleep(1);
	}
}

void *Get_Exosite(void *data)
{
	while(1){
		sem_wait(&Semaphore);
		printf("-");fflush(stdout);
		//sleep(5);
	}
}

int main( int argc, const char* argv[] )
{
/*
	char CmdLine[100];
	int Len;
	Len=sprintf(CmdLine, "cp test.txt text.%s", "tst");
	printf("%s, %d\n", CmdLine, Len);
	system(CmdLine);
*/
    pthread_t objThread[2];

	sem_init(&Semaphore, 0, 0);
	
    pthread_create(&objThread[0], NULL, Put_Exosite, NULL);
    pthread_create(&objThread[1], NULL, Get_Exosite, NULL);	

    pthread_detach(objThread[0]);
	pthread_detach(objThread[1]);
    pause();

	return -1;	
}




